<template>
  <view class="container">
    <view class="top-area">
      <view class="topTextBox">
        <image src="/static/images/regularUser/list.png" style="width: 25px; height: 25px;"></image>
        <view class="greeting">Hi, {{ userName }}</view>
      </view>
      <view class="topSearchBox">
        <view class="search-box">
          <image src="/static/images/regularUser/search.png" style="width: 15px; height: 15px; margin-right: 15px;"></image>
          <input type="text" placeholder="找寻您需要的帮助..." class="search-input" v-model="searchKeyword" />
        </view>
        <button class="btn" @click="searchServices">搜索</button>
      </view>
    </view>
    
    <view class="section-title">常用功能</view>
    <view class="quick-actions">
      <view class="q-item">
        <navigator url="/pages/regularUser/quickFuction/appointCard/appointCard" class="action-item">
          <image src="/static/images/regularUser/q-tf.png" class="action-icon"></image>
        </navigator>
        <text class="q-text">预约探访</text>
      </view>
      <view class="q-item">
        <navigator url="/pages/regularUser/quickFuction/takeMedicine/takeMedicine" class="action-item">
          <image src="/static/images/regularUser/q-yy.png" class="action-icon"></image>
        </navigator>
        <text class="q-text">提醒用药</text>
      </view>
      <view class="q-item">
        <navigator url="/pages/regularUser/goto/my/mygoto/serviceQuery" class="action-item">
          <image src="/static/images/regularUser/q-ls.png" class="action-icon"></image>
        </navigator>
        <text class="q-text">服务记录</text>
      </view>
      <view class="q-item">
        <navigator url="/pages/regularUser/quickFuction/askHelp/askHelp" class="action-item">
          <image src="/static/images/regularUser/q-qz.png" class="action-icon"></image>
        </navigator>
        <text class="q-text">请求帮助</text>
      </view>
    </view>
    
    <view class="section-title" style="display: flex; align-items: center; justify-content: space-between;">
      <view>热门服务</view>
    </view>
    
    <view class="services-grid">
      <navigator :url="`/pages/regularUser/goto/payService/serviceDetail/serviceDetail?id=${services[0].id}`" class="service-item">
        <image :src="services[0].image" class="service-icon"></image>
        <text class="ser-text">{{services[0].name}}</text>
        <text class="ser-sec-text">{{services[0].description}}</text>
        <view class="ser-bottom">
          <text class="pirce">￥{{services[0].price}}</text>
          <view style="display: flex; margin-right: 10px;">
            <image style="width: 15px; height: 15px;" src="/static/images/regularUser/star.png"></image>
            <view>{{services[0].rating}}</view>
          </view>
        </view>
      </navigator>
      
      <navigator :url="`/pages/regularUser/goto/payService/serviceDetail/serviceDetail?id=${services[1].id}`" class="service-item">
        <image :src="services[1].image" class="service-icon"></image>
        <text class="ser-text">{{services[1].name}}</text>
        <text class="ser-sec-text">{{services[1].description}}</text>
        <view class="ser-bottom">
          <text class="pirce">￥{{services[1].price}}</text>
          <view style="display: flex; margin-right: 10px;">
            <image style="width: 15px; height: 15px;" src="/static/images/regularUser/star.png"></image>
            <view>{{services[1].rating}}</view>
          </view>
        </view>
      </navigator>
      
      <navigator :url="`/pages/regularUser/goto/payService/serviceDetail/serviceDetail?id=${services[2].id}`" class="service-item">
        <image :src="services[2].image" class="service-icon"></image>
        <text class="ser-text">{{services[2].name}}</text>
        <text class="ser-sec-text">{{services[2].description}}</text>
        <view class="ser-bottom">
          <text class="pirce">￥{{services[2].price}}</text>
          <view style="display: flex; margin-right: 10px;">
            <image style="width: 15px; height: 15px;" src="/static/images/regularUser/star.png"></image>
            <view>{{services[2].rating}}</view>
          </view>
        </view>
      </navigator>
      
      <navigator :url="`/pages/regularUser/goto/payService/serviceDetail/serviceDetail?id=${services[3].id}`" class="service-item">
        <image :src="services[3].image" class="service-icon"></image>
        <text class="ser-text">{{services[3].name}}</text>
        <text class="ser-sec-text">{{services[3].description}}</text>
        <view class="ser-bottom">
          <text class="pirce">￥{{services[3].price}}</text>
          <view style="display: flex; margin-right: 10px;">
            <image style="width: 15px; height: 15px;" src="/static/images/regularUser/star.png"></image>
            <view>{{services[3].rating}}</view>
          </view>
        </view>
      </navigator>
    </view>
    
    <view class="section-title">优秀志愿者</view>
    <view class="volunteers-list">
      <navigator :url="`/pages/regularUser/goto/volunteerDetail/volunteerDetail?id=${volunteers[0].id}`" class="volunteer-item">
        <image :src="volunteers[0].avatar" class="volunteer-avatar"></image>
        <view class="volunteer-info">
          <view class="volunteer-name">{{volunteers[0].name}}</view>
          <view class="volunteer-desc">累积积分{{volunteers[0].points}}</view>
          <view class="volunteer-rating">⭐️ {{volunteers[0].rating}}</view>
        </view>
      </navigator>
      
      <navigator :url="`/pages/regularUser/goto/volunteerDetail/volunteerDetail?id=${volunteers[1].id}`" class="volunteer-item">
        <image :src="volunteers[1].avatar" class="volunteer-avatar"></image>
        <view class="volunteer-info">
          <view class="volunteer-name">{{volunteers[1].name}}</view>
          <view class="volunteer-desc">累积积分{{volunteers[1].points}}</view>
          <view class="volunteer-rating">⭐️ {{volunteers[1].rating}}</view>
        </view>
      </navigator>
    </view>

    <view class="bottom-nav">
      <navigator url="/pages/regularUser/regularUser" class="nav-item active">
        <image src="/static/images/regularUser/home-s.png" class="nav-icon"></image>
        <text>首页</text>
      </navigator>
      <navigator url="/pages/regularUser/goto/infomation/infomation" class="nav-item">
        <image src="/static/images/regularUser/info.png" class="nav-icon"></image>
        <text>消息</text>
      </navigator>
      <navigator url="/pages/regularUser/goto/my/my" class="nav-item">
        <image src="/static/images/regularUser/my.png" class="nav-icon"></image>
        <text>我的</text>
      </navigator>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      userName: '张XXX',
      searchKeyword: '',
      services: [
        {
          id: 1,
          name: '健康体检',
          description: '全面检查，健康无忧',
          price: '100.00',
          rating: '4.9',
          image: '/static/images/regularUser/service1.png'
        },
        {
          id: 2,
          name: '陪护散步',
          description: '轻松漫步，快乐相伴',
          price: '10.00',
          rating: '4.9',
          image: '/static/images/regularUser/service2.png'
        },
        {
          id: 3,
          name: '送餐上门',
          description: '美味即达，营养均衡',
          price: '5.00',
          rating: '4.9',
          image: '/static/images/regularUser/service3.png'
        },
        {
          id: 4,
          name: '心理疏导',
          description: '倾听心声，温暖心灵',
          price: '20.00',
          rating: '4.9',
          image: '/static/images/regularUser/service4.png'
        }
      ],
      volunteers: [
        {
          id: 1,
          name: '张XX',
          points: 120,
          rating: '4.9',
          avatar: '/static/images/regularUser/volunteer.png'
        },
        {
          id: 2,
          name: '李XX',
          points: 115,
          rating: '4.8',
          avatar: '/static/images/select/volunteer.png'
        }
      ]
    }
  },
  methods: {
    searchServices() {
      if (!this.searchKeyword.trim()) {
        uni.showToast({
          title: '请输入搜索关键词',
          icon: 'none'
        })
        return
      }
      
      uni.navigateTo({
        url: `/pages/regularUser/goto/searchResult/searchResult?keyword=${this.searchKeyword}`
      })
    }
  }
}
</script>

<style>
.container {
  background-color: white;
  color: #333;
  font-size: 16px;
  min-height: 100vh;
  padding-bottom: 80px;
}

.top-area {
  padding: 20px;
  padding-top: 40px;
  background-image: linear-gradient(#FCF2DE, #FFF);
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 8px rgba(0,0,0,0.1);
}

.topTextBox {
  display: flex;
  align-items: center;
  margin-bottom: 25px;
  margin-top: 30px;
}

.greeting {
  font-size: 19px;
  margin-left: 20px;
  font-weight: bold;
  color: #333;
}

.search-box {
  width: 65%;
  height: 40px;
  border-radius: 20px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  padding: 0 15px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  border: 1px solid #eee;
}

.search-input {
  flex: 1;
  padding: 0;
  font-size: 14px;
  border: none;
  outline: none;
  background: transparent;
}

.topSearchBox {
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn {
  background-color: #FD995E;
  color: white;
  width: 35%;
  font-size: 15px;
  height: 40px;
  border-radius: 20px;
  justify-content: center;
  margin: 10px;
  border: none;
  box-shadow: 0 2px 6px rgba(253, 153, 94, 0.3);
}

.btn:active {
  transform: scale(0.98);
}

.q-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.q-text {
  margin-top: 10px;
  font-size: 14px;
  color: #333;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  padding: 20px;
  background-color: #fff;
  border-radius: 15px;
  margin: 0 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 15px;
  background-color: white;
  border-radius: 12px;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.action-item:active {
  transform: scale(0.95);
  background-color: #FFF8F0;
}

.action-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

.section-title {
  padding-left: 22px;
  padding-top: 30px;
  padding-bottom: 10px;
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  padding: 0 15px 15px;
  background-color: #fff;
  border-radius: 15px;
  margin: 0 15px;
}

.service-item {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  padding: 10px;
  transition: all 0.2s;
  border: 1px solid #f5f5f5;
}

.service-item:active {
  transform: scale(0.98);
  box-shadow: 0 4px 12px rgba(253, 153, 94, 0.1);
}

.service-icon {
  width: 100%;
  height: 110px;
  margin-bottom: 10px;
  border-radius: 8px;
}

.ser-text {
  margin-bottom: 5px;
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.ser-sec-text {
  margin-bottom: 10px;
  font-size: 12px;
  color: #999;
  line-height: 1.4;
}

.ser-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.pirce {
  font-size: 16px;
  font-weight: bold;
  color: #FD995E;
}

.volunteers-list {
  display: flex;
  gap: 15px;
  padding: 0 15px 15px;
  background-color: #fff;
  border-radius: 15px;
  margin: 0 15px;
}

.volunteer-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  border-radius: 10px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border: 1px solid #f5f5f5;
  transition: all 0.2s;
}

.volunteer-item:active {
  transform: scale(0.98);
  background-color: #FFF8F0;
}

.volunteer-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
  border: 2px solid #FD995E;
}

.volunteer-info {
  text-align: center;
}

.volunteer-name {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.volunteer-desc {
  font-size: 12px;
  color: #999;
  margin-bottom: 5px;
}

.volunteer-rating {
  font-size: 12px;
  color: #FD995E;
  font-weight: bold;
}

.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 80px;
  background-color: white;
  position: fixed;
  bottom: 0;
  width: 100%;
  color: black;
  padding: 0 20px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  border-top: 1px solid #f0f0f0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #999;
  transition: all 0.2s;
}

.nav-item.active {
  color: #FD995E;
}

.nav-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 5px;
}

.more_box {
  font-size: 14px;
  color: #FD995E;
  margin-right: 25px;
  font-weight: normal;
}
</style>